package com.lam.multimedia;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnCreateContextMenuListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.lam.fundamental.R;

public class GetPicInfo extends Activity{
	private TextView tv_picInfo;
	private ImageView iv_picImageView;
	private static final int context_item1=Menu.FIRST;
	private static final int context_item2=Menu.FIRST+1;
	private static final int context_item3=Menu.FIRST+2;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.media_getpicinfo);
		tv_picInfo=(TextView)findViewById(R.id.tv_picInfo);
		iv_picImageView=(ImageView)findViewById(R.id.iv_pic);
		
		iv_picImageView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
			
			@Override
			public void onCreateContextMenu(ContextMenu menu, View v,
					ContextMenuInfo menuInfo) {
				// TODO Auto-generated method stub
				menu.add(Menu.NONE,context_item1,0,"Height");
				menu.add(Menu.NONE,context_item2,0,"Width");
				menu.add(Menu.NONE,context_item3,0,"other");
			}
			
			
		});
		
	}
	
	@Override
	public boolean onContextItemSelected(MenuItem item){
		Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.pic3);
		int height=bitmap.getHeight();
		int width=bitmap.getWidth();
		try {
			switch (item.getItemId()) {
			case context_item1:
				tv_picInfo.setText("Height"+width);
				break;

			default:
				tv_picInfo.setText("Width:"+height);
				break;
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return false;
		
	}
	
	
}
